package com.cosina.game.crystallight;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

import android.media.AudioManager;
import android.media.SoundPool;

import com.cosina.game.crystallight.ui.activity.ActivityStatus;
import com.cosina.game.crystallight.util.World;

public class MediaPlayerAdapter {
	
	private static SoundPool pool = new SoundPool(10, AudioManager.STREAM_MUSIC, 1);
	private static Map<Integer,Integer> key2key = new HashMap<Integer,Integer>();
	
	public static void init(CrystalLightActivity context){
		for(Field each : R.raw.class.getDeclaredFields()){
			try {
				int resid = (Integer)each.get(null);
				key2key.put(resid,pool.load(context, resid,1));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	private static void play(int resId){
		if(ActivityStatus.soundOn == World.YES){
			pool.play(key2key.get(resId), 1f, 1f, 1, 0, 0.5f);
		}
	}
	
	public static void menuArrival(){
		play(R.raw.menu_arrival);
	}
	
	public static void menuBtnclick(){
		play(R.raw.menu_btnclick);
	}

	public static void mapButtonClick() {
		play(R.raw.map_bclick);
	}
	
	public static void hpDown() {
		play(R.raw.shd_dec);
	}
	
	public static void victory() {
		play(R.raw.otb_victory);
	}
	
	public static void defeat() {
		play(R.raw.otb_defeat);
	}
	
	public static void mixture() {
		play(R.raw.kr_mix);
	}
	
	public static void upgrade() {
		play(R.raw.kr_enchant);
	}
	
	public static void crystalSelect() {
		play(R.raw.kr_select);
	}

	public static void buildVortex() {
		play(R.raw.b_vortex);
	}

	public static void buildPuddle() {
		play(R.raw.b_puddle);
	}

	public static void buildTower() {
		play(R.raw.b_tower);
	}
	
	public static void hitOne(){
		play(R.raw.hit1);
	}
	
	//TODO
	public static void hitTwo(){
		play(R.raw.hit2);
	}
	public static void hitThree(){
		play(R.raw.hit3);
	}
	public static void plug(){
		play(R.raw.kr_plug);
	}

	//TODO
	public static void explosion1() {
		play(R.raw.expl1);
	}
	public static void explosion2() {
		play(R.raw.expl2);
	}
	public static void dropCrystal() {
		play(R.raw.drop);
	}
	public static void cureHp() {
		play(R.raw.shd_click2);
	}
	public static void cannotCureHp() {
		play(R.raw.shd_click1);
	}
	public static void menuRoll() {
		play(R.raw.menu_roll);
	}
	public static void waveForce() {
		play(R.raw.wave_force);
	}
	public static void waveNext() {
		play(R.raw.wave_next);
	}
	public static void volumeDown() {
		play(R.raw.cg_ding1);
	}
	public static void volumeUp() {
		play(R.raw.cg_ding2);
	}
}
